/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import dao.ProductDAO;
import dao.mysql.ProductDAOImpl;
import javax.servlet.http.HttpServletRequest;
import utility.DBConnection;

/**
 *
 * @author Student
 */
public class ProductListAction implements Action{     
    
    @Override
    public String execute(HttpServletRequest request) {
        String url = "";
        DBConnection db = new DBConnection();
        ProductDAO dao = new ProductDAOImpl(db.getConnection());        
        try{
            request.setAttribute("products", dao.getAllProduct());
            url = "product_list.jsp";
        }catch(Exception ex){
            request.setAttribute("message", ex.getMessage());
            url = "errors.jsp";
        }
        return url;
    }
    
}
